package org.cfg;

import com.sojoys.artifact.build.data.base.BaseCfg;
import com.sojoys.artifact.tools.ToolMap;
import com.sojoys.artifact.factory.bytebuff.IByteBuff;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import java.util.HashMap;
import com.sojoys.artifact.constant.DataModelKeyEnum;
import java.util.ArrayList;
/**
 * 副本主线 ，描述主线副本的展示进度，被展示的可能是cg，可能是剧本对话，也可以是副本
 */
public class MainLineCfg extends BaseCfg<MainLineCfg> {

	/**
	 * 数据库表名称
	 */
	public static final String TABLE_NAME = "main_line";
	/**
	 * 完整类名称
	 */
	public static final String CLASS_NAME = "org.cfg.MainLineCfg"; 
	/**
	 * 字段个数
	 */
	public static final int COLUMN_COUNT= 4;
	/**
	 * 数据库源字段注释
	 */
	public static final String[] SOURCE_COLUMN_REMARKS = new String[]{"","章节组id","参数","类型",};
	/**
	 * 数据库源字段名字
	 */
	public static final String[] SOURCE_COLUMN_NAMES = new String[]{"id","levelGroupId","argument","type",};
	/**
	 * 拼音字段名字
	 */
	public static final String[] PINGYING_COLUMN_NAMES = new String[]{"id","levelGroupId","argument","type",};
	/**
	 * HashCode字段名字
	 */
	public static final Integer[] HASHCODE_COLUMN_NAMES = new Integer[]{3355,1572543446,-1589682499,3575610,};
	/**
	 * 字段基本类型
	 */
	public static final String[] COLUMN_BASICTYPES = new String[]{"int","int","String","int",};
	/**
	 * 字段引用类型
	 */
	public static final Class[] COLUMN_CLASSTYPES = new Class[]{Integer.class,Integer.class,String.class,Integer.class,};
	
	/**
	 * id
	 */
	private int id;
	
	/**
	 * 章节组id
	 */
	private int levelGroupId;
	
	/**
	 * 参数
	 */
	private String argument;
	
	/**
	 * 类型
	 */
	private int type;
	
	
	
	public static MainLineCfg builder() {
		MainLineCfg mainLineCfg = new MainLineCfg();
		return mainLineCfg;
	}
	
	/**
	 * id
	 */
	public int getId() {
		return id;
	}
	
	/**
	 * 章节组id
	 */
	public int getLevelGroupId() {
		return levelGroupId;
	}
	
	/**
	 * 参数
	 */
	public String getArgument() {
		return argument;
	}
	
	/**
	 * 类型
	 */
	public int getType() {
		return type;
	}
	
	
	protected Object[] getColumnNames(DataModelKeyEnum e){
		switch (e) {
		case SOURCE:
			return SOURCE_COLUMN_NAMES;
		case PINGYING:
			return PINGYING_COLUMN_NAMES;
		case HASHCODE:
			return HASHCODE_COLUMN_NAMES;
		case REMARKS:
			return SOURCE_COLUMN_REMARKS;
		default:
			return PINGYING_COLUMN_NAMES;
		}
	}
	
	protected String[] getBasicTypes(){
		return COLUMN_BASICTYPES;
	}
	
	protected Class[] getClassTypes(){
		return COLUMN_CLASSTYPES;
	}
	
	protected Object[] getColumeValues(){
		Object[] values = new Object[COLUMN_COUNT];
        values[0] = this.id;
        values[1] = this.levelGroupId;
        values[2] = this.argument;
        values[3] = this.type;
        return values;
	}
	
	protected MainLineCfg createColumeValues(Object[] vals) {
		this.id = (int)vals[0];
		this.levelGroupId = (int)vals[1];
		this.argument = (String)vals[2];
		this.type = (int)vals[3];
		return this;
	}
	
	protected Map<Object, Object> toMap(Object[] keys,Map<Object, Object> map){
        map.put(keys[0], this.id);
        map.put(keys[1], this.levelGroupId);
        map.put(keys[2], this.argument);
        map.put(keys[3], this.type);
        return map;
    }
    
    protected MainLineCfg createForMap(Object[] keys,Map map){
   		this.id = (int)map.get(keys[0]);
   		this.levelGroupId = (int)map.get(keys[1]);
   		this.argument = (String)map.get(keys[2]);
   		this.type = (int)map.get(keys[3]);
        return this;
    }
	
	
	protected JSONObject toJSONObject(Object[] keys,JSONObject obj){
        obj.put(keys[0], this.id);
        obj.put(keys[1], this.levelGroupId);
        obj.put(keys[2], this.argument);
        obj.put(keys[3], this.type);
        return obj;
    }
    
    protected MainLineCfg createForJSONObject(Object[] keys,JSONObject obj){
	    this.id = obj.getIntValue(keys[0]);
	    this.levelGroupId = obj.getIntValue(keys[1]);
	    this.argument = obj.getString(keys[2]);
	    this.type = obj.getIntValue(keys[3]);
        return this;
    }
    
    protected void writeBytes(IByteBuff byteBuf){
	    byteBuf.writeInt(this.id);
	    byteBuf.writeInt(this.levelGroupId);
	    byteBuf.writeString(this.argument);
	    byteBuf.writeInt(this.type);
    }
	
	protected MainLineCfg readBytes(IByteBuff byteBuf){
	    this.id = byteBuf.readInt(null);
	    this.levelGroupId = byteBuf.readInt(null);
	    this.argument = byteBuf.readString(null);
	    this.type = byteBuf.readInt(null);
	    return this;
	}
	
	public MainLineCfg deepCopy(){
		MainLineCfg mainLineCfg = null;
		try {
			mainLineCfg = (MainLineCfg) super.clone();
			return mainLineCfg;
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return mainLineCfg;
	}
//自定义内容起始位置
//自定义内容结束位置
}
